<template>
  <div>
    <!-- 添加按钮 -->
    <el-button type="primary" @click="willAdd">添加</el-button>

    <!-- 列表 -->
    <v-list @edit="willEdit" :list="list" @init="init"></v-list>

    <!-- 弹框 -->
    <v-form ref="form" :info="info" :list="list" @init="init"></v-form>
  </div>
</template>
<script>
import vList from "./components/list.vue";
import vForm from "./components/form.vue";
import { reqmenulist } from "../../request/api";
import toggle from "../../mixins/toggle.js"
export default {
  mixins:[toggle],
  components: {
    vList,
    vForm,
  },
  mounted() {
      //请数据
      this.init()
  },
  props: [],
  data() {
    return {
      // 1.初始化数据
      // info: {
      //   isshow: false,
      //   isAdd: true, //用来判断是添加的弹框还是编辑的弹框
      // },
      //列表的初始值
      list: [],
    };
  },
  methods: {
    // //2.点了添加
    // willAdd() {
    //   this.info = {
    //     isshow: true,
    //     isAdd: true,
    //   };
    // },
    // //6.点了编辑
    // willEdit(id) {
    //   this.info = {
    //     isshow: true,
    //     isAdd: false,
    //   };
    //   //通知form调用getOne
    //   this.$refs.form.getOne(id)
    // },
    //进来获取数据
    init() {
      //进来就请求数据
      reqmenulist({istree:true}).then((res) => {
        if (res.data.code == 200) {
          this.list = res.data.list;
        }
      });
    },
  },
};
</script>
<style lang="less" scoped>
</style>